//
//  CellForInformationVCSectionOneKindThree.m
//  echo
//
//  Created by dllo on 16/2/27.
//  Copyright © 2016年 Danny. All rights reserved.
//

#define WIDTH [UIScreen mainScreen].bounds.size.width / 414
#define HEIGHT [UIScreen mainScreen].bounds.size.height / 736

#import "CellForInformationVCSectionOneKindThree.h"
#import <DKNightVersion.h>
#import "ModelForInformationVCSectionOneKindThree.h"
#import <SDWebImage/UIImageView+WebCache.h>


@interface CellForInformationVCSectionOneKindThree ()
@property (nonatomic, retain)UIView *backView;
@property (nonatomic, retain)UILabel *labelForContent;
@property (nonatomic, retain)UIImageView *imageForPic;
@property (nonatomic, retain)UILabel *line;
@end

@implementation CellForInformationVCSectionOneKindThree

- (void)dealloc{
    [_backView release];
    [_labelForContent release];
    [_imageForPic release];
    [_line release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backView = [[UIView alloc]init];
        [self.contentView addSubview:self.backView];
        [self.backView release];
        
        self.labelForContent = [[UILabel alloc]init];
        [self.backView addSubview:self.labelForContent];
        [self.labelForContent release];
        self.labelForContent.font = [UIFont fontWithName:@"ArialUnicodeMS" size:15.0];
        self.labelForContent.numberOfLines = 0;
        self.labelForContent.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
        
        self.imageForPic = [[UIImageView alloc]init];
        [self.backView addSubview:self.imageForPic];
        [self.imageForPic release];
        
        self.line = [[UILabel alloc]init];
        [self.backView addSubview:self.line];
        [self.line release];
        
        [self handleNightModel];
    }
    return self;
}

- (void)passModel:(ModelForInformationVCSectionOneKindThree *)model{
    self.labelForContent.text = model.content;
    [self.imageForPic sd_setImageWithURL:[NSURL URLWithString:model.img_300]];
}

- (void)handleNightModel{
    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"夜间模式"]) {
        
        [DKNightVersionManager nightFalling];
        
    } else {
        
        [DKNightVersionManager dawnComing];
    }
    
    self.backView.dk_backgroundColorPicker = DKColorWithColors([UIColor whiteColor], [UIColor colorWithRed:17 / 256.f green:27 / 256.f blue:47 / 256.f alpha:1]);
    self.labelForContent.dk_backgroundColorPicker = DKColorWithColors([UIColor whiteColor], [UIColor colorWithRed:17 / 256.f green:27 / 256.f blue:47 / 256.f alpha:1]);
    self.imageForPic.dk_backgroundColorPicker = DKColorWithColors([UIColor whiteColor], [UIColor colorWithRed:17 / 256.f green:27 / 256.f blue:47 / 256.f alpha:1]);
    self.line.dk_backgroundColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    
}

- (void)layoutSubviews{
    self.backView.frame = self.contentView.frame;
    
    self.labelForContent.frame = CGRectMake(35 * WIDTH, 20 * HEIGHT, self.contentView.frame.size.width - 70 * WIDTH, 50 * HEIGHT);
    
    self.imageForPic.frame = CGRectMake(45 * WIDTH, 20 * HEIGHT + 50 * HEIGHT + 20 * HEIGHT, 200 * WIDTH, 200 * WIDTH);
    
    self.line.frame = CGRectMake(15 * WIDTH, 309 * HEIGHT, self.contentView.frame.size.width - 30 * WIDTH, 1 * HEIGHT);
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
